str='i love python'
print(str.capitalize())   # I love python

print(str.count('o'))     # 2

print(str.encode())       # b'i love python'
print(b'i love python'.decode())  #i love python

print('我爱祖国'.encode())  # b'\xe6\x88\x91\xe7\x88\xb1\xe7\xa5\x96\xe5\x9b\xbd'
print(b'\xe6\x88\x91\xe7\x88\xb1\xe7\xa5\x96\xe5\x9b\xbd'.decode())  # 我爱祖国

print(str.endswith('thon'))  # True

print(str.find('o'))    #3
print(str.index('o'))   #3
print(str.rfind('o'))   #11
print(str.rindex(('o')))  #11

str1='i love python 2023'
str2='python'
str3='123456789'
print(str1.isalnum())  #False
print(str.isalnum())   #False
print(str2.isalnum())  #True
print(str3.isalnum())  #True

print(str2.isalpha())  #True

print(str3.isdecimal()) #True

#print(str3.digit())    #取消

print(str2.islower())   #True

print(str3.isnumeric())  #True

print(str.isspace())    #False

str4='I Love Python'
print(str4.istitle())   #True

print(str4.isupper())   #False

print('*'.join(str4))   #I* *L*o*v*e* *P*y*t*h*o*n

#str2='python'
print(str2.ljust(20))   #python

print(str4.lower())     #i love python

str5='   python'
print(str5.lstrip())    #python
str6='python    '
print(str6.rstrip())   #python

print(max(str2))        #y
print(min(str2))        #h

#str='i love python'
print(str.replace('python','java')) #i love java
print(str)  #i love python

print(str2.split('o'))  #['pyth', 'n']
print(str2.startswith('p'))   #True
print(str2.upper())   #PYTHON





